package com.uaijug.dengue.app;

import java.util.List;

import com.uaijug.dengue.entidade.Foto;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class AdaptadorFocoSwitcher extends BaseAdapter {

	private Context ctx;
	private final List<Foto> fotos;
	private final android.view.ViewGroup.LayoutParams params;
	public AdaptadorFocoSwitcher(Context c, List<Foto> imagens,
			android.view.ViewGroup.LayoutParams params) {
		this.ctx = c;
		this.fotos = imagens;
		this.params = params;
	}
	public int getCount() {
		return fotos.size();
	}
	public Object getItem(int posicao) {
		return posicao;
	}
	public long getItemId(int posicao) {
		return posicao;
	}
	public View getView(int posicao, View convertView, ViewGroup parent) {
		ImageView img = new ImageView(ctx);
		Foto foto = fotos.get(posicao);
		Bitmap bitmap = BitmapFactory.decodeByteArray(foto.getFotoData(), 0, foto.getFotoData().length);
		img.setImageBitmap(bitmap);
		img.setAdjustViewBounds(true);
		img.setLayoutParams(params);
		return img;
	}

}
